package com.gelingqin.es.springbootdemo.controller;

import com.gelingqin.es.springbootdemo.service.ElasticsearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 *
 * 组件模板
 * @Author gelingqin
 * @Create 2021-12-17-15:44
 */
@RestController
@RequestMapping("/componentTpl/")
public class ComponentTplController {

    @Autowired
    private ElasticsearchService elasticsearchService;



    @RequestMapping("listAll")
    public Map listAll() {
        return elasticsearchService.performRequest("GET","/_component_template/",null,Map.class);
    }

    /**
     *
     * @param map
     * @return
     */
    @RequestMapping("create")
    public Map create(@RequestBody Map<String,Object> map){
        String id=(String)map.get("id");
        return elasticsearchService.performRequest("PUT","/_component_template/"+id,map.get("param"),Map.class);

    }

}
